#include <iostream>

using namespace std;

struct Node
{
    int data;
    Node* next;
};

int main(int argc, char const *argv[])
{
    Node* head = new Node;
    Node* tail = head;

    Node* p0 = new Node;
    tail->next = p0;
    p0->next = nullptr;
    tail = p0;

    int n;
    cin >> n;
    for (size_t i = 1; i < n; i++)
    {   
        int k , flag;
        Node* tmp = nullptr;

        cin >> k >> flag;

        for (Node* p=p0; p != NULL ; p = p->next)
        {   
            
            Node* new_node = new Node;
            if(flag){
                new_node->next =p->next;
                p->next = new_node;
            }else{
                new_node->next= p;
                tmp->next = new_node;                
            }
            tmp = p;
        }

        for(Node* p=p0; p != NULL; p=p->next){
            cout << p->data;
        }
        
    }
    
    
    return 0;
}


